package cn.com.nes.site.service.project;

import cn.com.nes.mybatis.agent.project.entity.ProjectCustomerRelationship;
import cn.com.nes.site.entity.bo.project.ProjectCustomerRelationshipPageBO;
import cn.com.nes.site.service.project.dto.ProjectCustomerRelationCountDTO;
import cn.com.nes.site.service.project.dto.ProjectRelationshipDTO;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;

import java.util.Date;
import java.util.List;

/**
 * @author yishuai
 */
public interface ProjectCustomerRelationshipService extends IService<ProjectCustomerRelationship> {

    List<ProjectCustomerRelationship> getAllRelationship(String projectId) throws Exception;


    List<ProjectCustomerRelationship> getRelationshipsExcludeMain(String projectId) throws Exception;


    public List<ProjectCustomerRelationship> getRelationshipsExcludeMain(String projectId,
            String customerId) throws Exception;


    List<ProjectCustomerRelationship> getRelationshipsForImport(String projectId) throws Exception;


    ProjectCustomerRelationship getRelationshipsForMain(String projectUuid, String opportunityUuid) throws Exception;


    ProjectCustomerRelationship getMainRelationshipByOpportunityUuid(String opportunityUuid) throws Exception;

    List<ProjectCustomerRelationship> getRelationshipsForMain(String projectId) throws Exception;


    Page<ProjectRelationshipDTO> getRelationshipsExcludeMain(ProjectCustomerRelationshipPageBO bo) throws Exception;


    ProjectCustomerRelationship hasMainCustomer(String projectUuid) throws Exception;


    /**
     * 删除导入用户
     * @param projectUuid   项目ID
     * @param operateUserId 操作人
     * @param operateDate   操作时间
     */
    void deleteImportCustomer(String projectUuid, Long operateUserId, Date operateDate) throws Exception;


    /**
     * 根据行政区划代码和项目id查询客户id列表
     */
    List<String> getCustomerIdListByXzqhdm(String projectUuid, String xzqhdm);


    /**
     * 根据客户id删除项目-客户关系表数据
     */
    void deleteImportCustomerByCustomerId(List<String> customerIdList, Long operateUserId, Date operateDate);


    List<ProjectCustomerRelationCountDTO> getCustomerCountOfProject(List<String> projectUuids) throws Exception;


    /**
     * 根据商机id删除项目-客户关系表数据
     */
    void updateRelationshipsByMainCustomerId(String projectUuid, String mainOpportunityId, Long operateUserId,
            Date operateDate);


    /**
     * 根据主客户id更新项目关联关系
     */
    void deleteOpportunityId(List<String> opportunityIdList, String mainOpportunityId, Long operateUserId,
            Date operateDate);


    /**
     * 获取与指定主商机相关的所有项目客户关系。
     * @param mainOpportunityUuid 主商机的唯一标识符
     * @return 与指定主商机相关的项目客户关系列表
     */
    List<ProjectCustomerRelationship> getBeRelatedOfRelationships(String mainOpportunityUuid) throws Exception;


    ProjectCustomerRelationship getOtherRelationship(String customerUuid, String mainOpportunityUuid) throws Exception;

    /**
     * 查询客户和项目已保存的关系数据
     */
    ProjectCustomerRelationship queryProjectCustomerRelationship(String customerId, String projectUuid);
}
